	 <div class="box box-default" style="padding-left:5px;padding-right:5px;border-radius:5px">
        <div class="box-header with-border">
          <h3 class="box-title">查询</h3>
          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button>
          </div>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
		    #for(i = 0; i < col.length; i++)
		      <div class="row" style="padding-bottom:10px;">
		       #for(y:col[i])
		                   #setLocal(id=getCompentId(searchid,y.index,y.id))
			               <div class="col-sm-#(y.type=='laydate'?4:3)" style="padding-left:5px;padding-right:5px;">
			                    <div class="input-group">
									<label class="input-group-addon control-label">
										#(y.name??)
									</label>
									#if(y.type=="laydate")
									    <div id="#(id)_divinput">
										  <input type="text"  id="#(id)" class="form-control" style="#(y.style??'width:100%;')"/>
									    </div>
									    <span class="input-group-addon" style="padding:5px;">~</span>
										<input type="text"  id="#(id)temp" class="form-control" style="#(y.style??'width:100%;')"/>
									#else
									   <div id="#(id)_divinput">
										<input type="text"  id="#(id)" class="form-control" style="#(y.style??)"/>
									   </div>
									#end
								</div>
							</div>
							<input type="hidden" id="#(id)_hides"/>
							<input type="hidden" id="#(id)_expre"/>
							<span class="input-group-btn"></span>
				#end
				</div>	
			#end
			<div class="box-footer">
		            <div style="text-align:center">
						<button class="btn btn-sm btn-info" id="_#(searchid??)_gotoSearch">查询</button>
						<button class="btn btn-sm btn-white" id="_#(searchid??)_gotoReset">重置</button>
				    </div>	
		    </div>	
          <!-- /.row -->
        </div>
        <!-- /.box-body -->
      </div>
      <!-- /.box -->
	<script type="text/javascript">
		var isAutoPage = true;
		#if(jqGrid != null)
    		var jqGridId = "#(jqGrid??)"
    	    $jqGrid = $("#"+jqGridId);
    	#end
		$(function () {
			if(!$jqGrid){
			    	$jqGrid =  $(grid_selector);
			}
		    $("#_#(searchid??)_gotoSearch").bind("click", function () {
		    	var filter = "";
		        if (typeof (_filter) != "undefined") {
		            filter = _filter;
		        }
		        var where = (BasicTool.isEmpty(filter)) ? "" : filter.replace("}", "");
		    	#for(x : col)
		    		  #for(y : x)
		    			  #setLocal(id=getCompentId(searchid,y.index,y.id))
		    			  var key = "#(y.index)";
		    	          var type = "#(y.type)";
				    	  var expre = "#(y.expre)";
				    	  var value = $("##(id)").val();
			    	      if(BasicTool.isNotEmpty(key) && BasicTool.isNotEmpty(value) && type!="laydate") {
					          if(expre=='like'){
					        	 where += (BasicTool.isEmpty(where) ? "{" : ",") + "\"" + key +" " + expre + "\":\"" +'%'+ value + '%' + "\"";
					          }else{
					        	 where += (BasicTool.isEmpty(where) ? "{" : ",") + "\"" + key +" " + expre + "\":\"" + value + "\"";
					          }
					       }
					       #if(y.type=="laydate")
					           var laydate2 = $("##(id)temp").val();
					           key = key+"_isdate";
					    	   if(BasicTool.isNotEmpty(value)&&BasicTool.isNotEmpty(laydate2)){
							       where += (BasicTool.isEmpty(where) ? "{" : ",") + "\"" + key +" " + expre + "\":\"" + value + "\"";
							       where += ",\"" + key +" <=\":\"" + laydate2 + "\"";
							   }else if(BasicTool.isNotEmpty(value)&&BasicTool.isEmpty(laydate2)){
								   where += (BasicTool.isEmpty(where) ? "{" : ",") + "\"" + key +" " + expre + "\":\"" + value + "\"";
							   }else if(BasicTool.isEmpty(value)&&BasicTool.isNotEmpty(laydate2)){
								   where += (BasicTool.isEmpty(where) ? "{" : ",") + "\"" + key +" <=\":\"" + laydate2 + "\"";
							   }
					       #end
		    		  #end
		    	#end
		        if (BasicTool.isNotEmpty(where)) {
		            where += "}";
		        }
		        where = encodeURI(where);
		        var pageNum = $jqGrid.getGridParam('page');
		        $jqGrid.jqGrid("setGridParam", {datatype:'json', postData: { where: where,exwhere:exwhere }, page: (isAutoPage) ? pageNum : 1 }).trigger("reloadGrid");
		    });
		
		    $("#_#(searchid??)_gotoReset").bind("click", function () {
		    	reset()
		        reloadGrid();
		    });
		    
		    initpPram();
		});
		
		function reset(){
			#for(x : col)
				#for(y : x)
					#setLocal(filedtype = y.type,id=getCompentId(searchid,y.index,y.id))
					#if(filedtype.indexOf("select_") >= 0||filedtype.indexOf("selectDept") >= 0||filedtype.indexOf("selectUser") >= 0||filedtype.indexOf("selectRole") >= 0)
						$("##(id) option:first").prop("selected", 'selected');
					#else if(filedtype.indexOf("opentree_") >= 0)
					     $("##(id)_INPUT").val('');
					     $("##(id)").val('');
					#else if (filedtype=="date"||filedtype=="laydate"||filedtype=="text")
						 $("##(id)").val('');
					     $("##(id)temp").val('');
					#else
					#end
				#end
			#end
		}
		
		/* function initDate(){
			#for(x : col)
		    	 #for(y : x)
			    	 #setLocal(filedtype = y.type,id=getCompentId(searchid,y.index,y.id))
					 #if(filedtype == "laydate" )
						 getlaydate('#(id)',"#(y.dateType??'date')","#(y.format??'yyyy-MM-dd')");
			    		 getlaydate('#(id)temp',"#(y.dateType??'date')","#(y.format??'yyyy-MM-dd')");
				     #end
			     #end
			#end
		} */
		
		function initpPram(){
			#for(x : col)
				#for(y : x)
				    #setLocal(filedtype = y.type,id=getCompentId(searchid,y.index,y.id))
				    #if(filedtype.indexOf("select_") >= 0)
				    	var type = "#(filedtype)";
				        var code = type.replace("select_", "");
				        $.post("/cache/getSelectById", { code: code,id:"#(id)"}, function (data) {
				        	if (data.code == 0) {
				            	$("##(id)_divinput").html(data.data);
				            }
				        }, "json");
				    #else if (filedtype == "selectDept")
				        $.post("/cache/getDeptSelectById", {id:"#(id)"}, function (data) {
				            if (data.code == 0) {
				            	$("##(id)_divinput").html(data.data);
				            }
				        }, "json");
				    #else if (filedtype == "selectUser")
				        $.post("/cache/getUserSelectById", {id:"#(id)" }, function (data) {
				            if (data.code == 0) {
				                $("##(id)_divinput").html(data.data);
				            }
				        }, "json");
				    #else if (filedtype== "selectRole")
				        $.post("/cache/getRoleSelectById", {id:"#(id)" }, function (data) {
				            if (data.code == 0) {
				                $("##(id)_divinput").html(data.data);
				            }
				        }, "json");
				    #else if (filedtype.indexOf("opentree") >= 0)
				        var html = "<input type=\"text\"  id=\"#(id)_INPUT\" class=\"form-control\" style=\"#(y.style??)\"/>";
				        html += "<input type=\"hidden\"  id=\"#(id)\" />";
			            $("##(id)_divinput").html(html);
			            
				        $("##(id)_INPUT").bind("click",function(){
				        	openTree("#(filedtype)","#(id)","#(y.name)","#(y.source??'')","#(y.check??'radio')","#(y.where??'')","#(y.val??'')");
				        });
				    #else if (filedtype == "date")
				    	$("##(id)_divinput").html("<input type=\"datetime-local\"  id=\"#(id)\" class=\"form-control\" style=\"#(y.style??)\"/>");
				    #else if (filedtype == "checkbox")
				    	var checkboxhtml = "<label style=\"#(y.style??'margin-top:5px;margin-left:20px;')\"> <input id=\"#(id)_chb\" type=\"checkbox\" class=\"minimal\" /></label> <input type=\"hidden\" id=\"#(id)\" value=\"\">";
				    	$("##(id)_divinput").html(checkboxhtml);
				    	$('##(id)_chb').on('ifChanged', function(obj){
				    	      if(obj.currentTarget.checked){
				    	      	$("##(id)").val("1");
				    	      }else{
				    	      	$("##(id)").val("");
				    	      }
				    	})
				    #else if(filedtype == "laydate" )
						 getlaydate('#(id)',"#(y.dateType??'date')","#(y.format??'yyyy-MM-dd')");
			    		 getlaydate('#(id)temp',"#(y.dateType??'date')","#(y.format??'yyyy-MM-dd')");
				    #else if (filedtype == "text")
				    	resetInput('#(id)');
				    #else
					#end
				#end
			#end
		}
		
		function resetInput(num) {
		    $("#_"+num).html("<input type=\"text\"  id=\""+num+"\"  class=\"form-control\" style=\"#(y.style??)\"/>");
		}
		
		function openTree(type,index,name,source,check,where,val){
			var url = "/ztree/open/"+type+"-"+index+"-"+name+"-"+source+"-"+check+"-"+where+"-0-0-"+val;
			url = encodeURI(url);
			layer.open({
        	    type: 2,
        	    title:"树形选择",
        	    area: ["250", "420px"],
        	    fix: false, //不固定
        	    maxmin: true,
        	    content: url
        	});
		}
		function getlaydate(id,type,format){
			var _elem= id;
			laydate.render({
			    elem: '#'+_elem,
			    type: type,
			    format: format,
			    change: function(value, date, endDate){
			    }
			});
		}
	</script>
<script src="/static/laydate/laydate.js"></script>

<link rel="stylesheet" href="/static/assets/iCheck/all.css">
<script src="/static/assets/iCheck/icheck.min.js"></script>
<script>
$('input[type="checkbox"].minimal').iCheck({
    checkboxClass: 'icheckbox_flat-green',
    radioClass   : 'iradio_flat-green'
})
</script>
